//
//  SAInventoryWaterCell.m
//  yidiantong
//
//  Created by 黄志刚 on 2020/11/4.
//

#import "SAInventoryWaterCell.h"
#import "SAInventoryWaterModel.h"

@interface SAInventoryWaterCell ()

@property (nonatomic, strong) UIView *line;

@property (nonatomic, strong) UILabel *operationLab;
@property (nonatomic, strong) UILabel *operationIDLab;
@property (nonatomic, strong) UILabel *sizeLab;
@property (nonatomic, strong) UILabel *dateLab;
@property (nonatomic, strong) UILabel *putLab;
@property (nonatomic, strong) UILabel *outLab;

@end

@implementation SAInventoryWaterCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initUI];
    }
    return self;
}

-(void)setModel:(SAInventoryWaterList *)model {
    _model = model;
    _operationLab.text = model.salesType;
    _operationIDLab.text = model.salesNo;
    _sizeLab.text = [NSString stringWithFormat:@"%@,%@",model.colourName,model.sizeName];
    _dateLab.text = model.updateTime;
    if (model.salesCount == 0) {
        _putLab.text = @"--";
        _outLab.text = @"--";
    }else if (model.salesCount > 0) {
        _putLab.text = [NSString stringWithFormat:@"%0.f",model.salesCount];
        _outLab.text = @"--";
    }else {
        _putLab.text = @"--";
        _outLab.text = [NSString stringWithFormat:@"%0.f",model.salesCount/-1];
    }
}

#pragma mark - initUI
-(void)initUI {
    self.contentView.backgroundColor = kLineColor;
    [self.contentView addSubview:self.line];
    
    [self.contentView addSubview:self.operationLab];
    [self.contentView addSubview:self.operationIDLab];
    [self.contentView addSubview:self.sizeLab];
    [self.contentView addSubview:self.dateLab];
    [self.contentView addSubview:self.putLab];
    [self.contentView addSubview:self.outLab];

}

#pragma mark - lazy
-(UIView *)line {
    if (!_line) {
        _line = [[UIView alloc] initWithFrame:SARectMake(0, 0, kBaseScreenWidth, 44)];
        _line.backgroundColor = [UIColor whiteColor];
    }
    return _line;
}

-(UILabel *)operationLab {
    if (!_operationLab) {
        _operationLab = [[UILabel alloc] initWithFrame:SARectMake(30, 2, 100, 20)];
        _operationLab.textColor = kBlackColor;
        _operationLab.textAlignment = NSTextAlignmentLeft;
        _operationLab.numberOfLines = 0;
        _operationLab.font = kFont(13);
    }
    return _operationLab;
}

-(UILabel *)operationIDLab {
    if (!_operationIDLab) {
        _operationIDLab = [[UILabel alloc] initWithFrame:SARectMake(30, 22, 100, 20)];
        _operationIDLab.textColor = kLightgGrayColor;
        _operationIDLab.textAlignment = NSTextAlignmentLeft;
        _operationIDLab.numberOfLines = 0;
        _operationIDLab.font = kFont(13);
    }
    return _operationIDLab;
}

-(UILabel *)sizeLab {
    if (!_sizeLab) {
        _sizeLab = [[UILabel alloc] initWithFrame:SARectMake(130, 2, 100, 20)];
        _sizeLab.textColor = kBlackColor;
        _sizeLab.textAlignment = NSTextAlignmentLeft;
        _sizeLab.numberOfLines = 0;
        _sizeLab.font = kFont(13);
    }
    return _sizeLab;
}

-(UILabel *)dateLab {
    if (!_dateLab) {
        _dateLab = [[UILabel alloc] initWithFrame:SARectMake(130, 22, 100, 20)];
        _dateLab.textColor = kLightgGrayColor;
        _dateLab.textAlignment = NSTextAlignmentLeft;
        _dateLab.numberOfLines = 0;
        _dateLab.font = kFont(13);
    }
    return _dateLab;
}

-(UILabel *)putLab {
    if (!_putLab) {
        _putLab = [[UILabel alloc] initWithFrame:SARectMake(230, 0, 70, 44)];
        _putLab.textColor = kBlackColor;
        _putLab.textAlignment = NSTextAlignmentCenter;
        _putLab.numberOfLines = 0;
        _putLab.font = kFont(13);
    }
    return _putLab;
}

-(UILabel *)outLab {
    if (!_outLab) {
        _outLab = [[UILabel alloc] initWithFrame:SARectMake(300, 0, 70, 44)];
        _outLab.textColor = kBlackColor;
        _outLab.textAlignment = NSTextAlignmentCenter;
        _outLab.numberOfLines = 0;
        _outLab.font = kFont(13);
    }
    return _outLab;
}



@end
